package com.zjj.dao;

import com.zjj.pojo.Orders;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface OrdersMapper {


    @Select("SELECT * FROM tb_order WHERE user_id = #{id}")
    @Results({
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "number", column = "number")})
    List<Orders> selectOrdersByUserId(int user_id);





    @Select("SELECT * FROM tb_order WHERE id = #{id}")
    @Results({
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "number", column = "number"),
            @Result(property = "products", column = "id",
                    many = @Many(select = "com.zjj.dao.ProductMapper.selectProductByOrdersId"))
    })
    Orders selectOrderById(int id);


}
